//
//  EJShapedButton.m
//  EJiangOSbeta
//
//  Created by ejiang on 2021/4/8.
//  Copyright © 2021 Joyssom. All rights reserved.
//

#import "EJShapedButton.h"

@implementation EJShapedButton

- (void)setPath:(UIBezierPath *)path {
    _path = path;
    CAShapeLayer * shapeLayer = [[CAShapeLayer alloc] init];
    shapeLayer.path = path.CGPath;
    self.layer.mask = shapeLayer;
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
    BOOL result = [super pointInside:point withEvent:event];
    if (result) {
        if (_path == nil) {
            return YES;
        }
        if ([_path containsPoint:point]) {
            return YES;
        }
    }
    return NO;
}

@end
